import binascii
# following imports are required by PKI
import Crypto #pip install pycrypto
import Crypto.Random
from Crypto.Hash import SHA
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5

import datetime
class Student:
    Name = ''
    Credits = 20.0
    def __init__(self):
        random = Crypto.Random.new().read
        self._private_key = RSA.generate(1024, random)
        self._public_key = self._private_key.publickey()
        self.Name = binascii.hexlify(self._public_key.exportKey(format='DER')).decode('ascii')


class Transaction:
    def __init__(self, sender, recipient, value):
        if sender.Credits>value:
           sender.Credits -= value
           recipient.Credits += value
           self.time = datetime.datetime.now()
           print('Transaction finished at %s' %(self.time))

StuA = Student()
StuB = Student()
tran = Transaction(StuA,StuB,10)

print('Student: %s has %f credits' % (StuA.Name,StuA.Credits))
print('Student: %s has %f credits' % (StuB.Name,StuB.Credits))